package com.study.七大原则.o3依赖倒置原则;

public class DependencyInversion2 {

    public static void main(String[] args) {
        //客户端无需改变
        Person person = new Person();
        person.receive(new Email());
        person.receive(new WeiXin());
        person.receive(new Msg());
    }

    //定义一个接口
    interface IReceiver{
        public String getInfo();
    }

    static class Email implements IReceiver{

        @Override
        public String getInfo() {
             return "电子邮件信息:hello，world";
        }
    }

    static class WeiXin implements IReceiver{

        @Override
        public String getInfo() {
             return "微信信息:hello，world";
        }
    }

    static class Msg implements IReceiver{

        @Override
        public String getInfo() {
             return "短信信息:hello，world";
        }
    }


    static class Person{
        public void receive(IReceiver receiver){
            System.out.println(receiver.getInfo());
        }
    }
}
